<!doctype html>
<html>
<head>
	<meta charset="utf-8"/>
	<title>人力资源管理系统</title>
	
	<link rel="stylesheet" href="../css/layout.css" type="text/css" media="screen" />
	<script src="../js/jquery-1.5.2.min.js" type="text/javascript"></script>
	

	<script src="../js/hideshow.js" type="text/javascript"></script>
	<script src="../js/jquery.tablesorter.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="../js/jquery.equalHeight.js"></script>
	<script src="../js/schedule.js" type="text/javascript"></script>

    <script type="text/javascript">
    
    $(function(){
        $('.column').equalHeight();
    });
</script>
 <script src="../api/api.js" type="text/javascript"></script>

</head>


<body>

	<header id="header">
		<hgroup>
			<h1 class="site_title"><a href="index.html">人力资源管理系统</a></h1>
			<h2 class="section_title"></h2><div class="btn_view_site"><a href="login.html">注销</a></div>
		</hgroup>
	</header> <!-- end of header bar -->
	
	<section id="secondary_bar">
		<div class="user">
			<p id="staff"></p>
			<!-- <a class="logout_user" href="#" title="Logout">Logout</a> -->
		</div>
		<div class="breadcrumbs_container">
			<article class="breadcrumbs"><a href="index.html">系统管理中心</a> <div class="breadcrumb_divider"></div> <a class="current">应聘信息录入</a></article>
			<div class="current-time"></div>
		</div>
	</section><!-- end of secondary bar -->
	
	<aside id="sidebar" class="column">
	<h3>人员管理</h3>
	<ul class="toggle">
		<li class="icn_new_article"><a href="lecadd.html">人员信息录入</a></li>
		<li class="icn_categories"><a href="leclist.html">人员信息查看</a></li>
		
		
	</ul>
	
	<h3>应聘信息管理</h3>
    <ul class="toggle">
        <li class="icn_new_article"><a href="hireinfo.html">应聘信息录入</a></li>
        <li class="icn_see_onlineUser"><a href="rencaiku.html">应聘信息查看</a></li>
         <li class="icn_categories"><a href="approval.html">应聘信息审核</a></li>
    </ul>

		<h3>公告管理</h3>
		<ul class="toggle">
			<li class="icn_new_article"><a href="notice_add.html">公告添加</a></li>

			<li class="icn_categories"><a href="notice_edit.html">公告编辑</a></li>

			<li class="icn_see_onlineUser"><a href="notice_check.html">公告查看</a></li>



		</ul>
	
	
	
	
	<footer>
		
	</footer>
</aside><!-- end of sidebar -->
	
	<section id="main" class="column">
		
			<article class="module width_full">
				<header><h3>应聘信息录入</h3></header>
					<div class="module_content">
					<div class="field_set">
					<fieldset style="width:300px;float:left " >
								<label>姓名</label>
								<input style="width:250px"type="text" name="username" id="username" >
							</fieldset>
							<fieldset style="width:90px;float:left;margin-left:100px;">
								<label style="width: 90px">性别</label>
								 <input type="radio" name="sex" style="margin-left:10px;" value="1" checked  />男
								<input type="radio" name="sex" value="0"  />女
							</fieldset>

					
					</div>

						<div class="field_set">

							<fieldset style="width:300px;float:left;" >
								<label>应聘职位</label>
								<input style="width:250px"type="text" name="position" id="position" >
							</fieldset>

							<fieldset style="width:40%; float:left;margin-left: 100px" >
								<label>出生日期</label>
								<input type="text" id="birthday" class="birthday" style="width:85%;float:left" onclick="showDatePicker()"  />
								<div style=" position:relative; padding-top:30px;hover:#4493da">
									<div id="schedule-box" class="boxshaw" style=""></div>
								</div>
							</fieldset>


						</div>



					<div class="field_set">
					<fieldset  style="width:300px;float:left;">
								<label>身份证号码</label>
								<input  style="width:250px" type="text" name="identity" id="identity"  >
							</fieldset>
							<fieldset style="width:300px;float:left;margin-left:100px">
								<label>年龄</label>
								<input  id="age" style="width:250px;" type="text" name="age" >
							</fieldset>
							
					
					</div>
					<div class="field_set">
					<fieldset  style="width:300px;float:left;">
								<label>专业</label>
								<input  style="width:250px" type="text" name="major" id="major" >
							</fieldset>
							<fieldset style="width:300px;float:left;margin-left:100px">
								<label>学历</label>
								<input  style="width:250px;" type="text" name="degree" id="degree">
							</fieldset>
							
					
					</div>
					<div class="field_set">
					<fieldset  style="width:300px;float:left;">
								<label>电话</label>
								<input  style="width:250px" type="text" name="tel" id="tel" >
							</fieldset>
							<fieldset style="width:300px;float:left;margin-left:100px">
								<label>E-mail</label>
								<input  style="width:250px;" type="text" name="email" id="email">
							</fieldset>
							
					
					</div>
							<fieldset style="width:100%; float:left; margin-right:1%;">
								<label>工作经验</label>
								<textarea rows="6" name="experience" id="experience"></textarea>
							</fieldset>
							
							
							
							
							</fieldset><div class="clear"></div>			
					</div>
				<footer>
					<div class="submit_link">
						<input type="hidden" name="id" value="{$data.id|default:''}">
						<input type="submit" name="submit"  value="保存" class="save_btn" id="submit">
						<button class="reset" id="reset" >重置</button>
					</div>
					
				</footer>
			</article>
		<div class="spacer"></div>
	</section>
	<script type="text/javascript">
			function $getId(id) {
                return document.getElementById(id);
            }
	//显示日期
	  function checkRadio(radioname) {
                let rLists = document.getElementsByName(radioname),
                    radioV,
                    i;
                for (i = 0; i < rLists.length; i++) {
                    if (rLists[i].checked) {
                        radioV = rLists[i].value;
                        return radioV;
                    }
                }
                //如果没有选中，就返回第一个单选款的值
                if (i == rLists.length) {
                    radioV = rLists[0].value;
                }
                return radioV;
            }

       		
			
                let username=$getId("username"),
                    identity=$getId("identity"),
                    age=$getId("age"),
                    major=$getId("major"),
                    degree=$getId("degree"),
                    tel=$getId("tel"),
                    email=$getId("email"),
                    position=$getId("position"),
                   sex=checkRadio("sex"),
                   birthday=$getId("birthday"),
                   experience=$getId("experience");
                  //  reset=$getId("reset");
                
                
                reset.onclick=function(){
                	//alert(".....")
                	username.value="";
                	identity.value="";
                	age.value="";
                	major.value="";
                	degree.value="";
                	position.value="";
                	tel.value="";
                	email.value="";
                	experience.value="";
                document.getElementsByName("sex")[0].checked = true;
                	
                }
                
                submit.onclick=function()
                {
                	 if(checkIsEmpty()){
                		 let data={
                             	
                             	username:username.value,
                             	identity:identity.value,
                             	birthday: birthday.innerHTML ? birthday.innerHTML : setBirthday(),
                             	age:age.value,
                             	major:major.value,
                             	degree:degree.value,
                             	tel:tel.value,
                             	sex:sex,
                             	position:position.value,
                             	email:email.value,
                             	experience:experience.value,
                             	approval:"是"
                             	};
                         myApi.user.addCandidate(data, function(err, result) {
                             if (err) {
                                alert(err);
                             } else {
                                 //如果添加成功就将页面跳转到显示人员信息页面
                                 alert("应聘人员信息添加成功");
                                 location.href = "./rencaiku.html";
                             }
                         });
                         };
                }
                
                function checkIsEmpty() {
                //	alert("jinru");
                    if (!username.value.trim()) {
                        username.focus();
                        alert("请填写姓名");
                        return false;
                    } else if (!identity.value.trim()) {
                        identity.focus();
                        alert("请输入用户密码");
                        return false;
                    } else if (!age.value.trim()) {
                        age.focus();
                        alert("请输入人员简介");
                        return false;
                    }
                    return true;
                }
               
                
    
                	
                	
              
                
                
	</script>

	<script>

        let staff = document.getElementById("staff");

        $(staff).text(localStorage.getItem("username"));

        function showDatePicker() {
            if ($getId("schedule-box").style.display == "block") {
                $getId("schedule-box").style.display = "none";
            } else if ($getId("schedule-box").style.display == "none" || !$getId("schedule-box").style.display) {
                $getId("schedule-box").style.display = "block";
            }
        }

        var mySchedule = new Schedule({
            el: '#schedule-box',
            //date: '2018-9-20',
            clickCb: function(y, m, d) {
                document.getElementById('birthday').value = y + '-' + m + '-' + d
            },
            nextMonthCb: function(y, m, d) {
                document.getElementById('birthday').value = y + '-' + m + '-' + d
            },
            nextYeayCb: function(y, m, d) {
                document.getElementById('birthday').value = y + '-' + m + '-' + d
            },
            prevMonthCb: function(y, m, d) {
                document.getElementById('birthday').value = y + '-' + m + '-' + d
            },
            prevYearCb: function(y, m, d) {
                document.getElementById('birthday').value = y + '-' + m + '-' + d
            }
        });

        function setBirthday() {
            let date = new Date();
            return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
        }

        function checkRadio(radioname) {
            let rLists = document.getElementsByName(radioname),
                radioV,
                i;
            for (i = 0; i < rLists.length; i++) {
                if (rLists[i].checked) {
                    radioV = rLists[i].value;
                    return radioV;
                }
            }
            //如果没有选中，就返回第一个单选款的值
            if (i == rLists.length) {
                radioV = rLists[0].value;
            }
            return radioV;
        }



	</script>
	


</body>

</html>